import request from '@/utils/request'

export function getProductPage(params) {
  return request({
    url: '/api/product/page',
    method: 'get',
    params
  })
}

export function getProductById(id) {
  return request({
    url: `/api/product/${id}`,
    method: 'get'
  })
}

export function saveProduct(data) {
  return request({
    url: '/api/product',
    method: 'post',
    data
  })
}

export function updateProduct(data) {
  return request({
    url: '/api/product',
    method: 'put',
    data
  })
}

export function deleteProduct(id) {
  return request({
    url: `/api/product/${id}`,
    method: 'delete'
  })
}

export function updateStock(id, quantity) {
  return request({
    url: `/api/product/stock/${id}`,
    method: 'put',
    params: { quantity }
  })
}
